﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        initControl();
        gridList()
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            treeGrid: true,
            ExpandColumn: "OrganizeId",
            postData: { keyword: $("#txt_keyword").val(), organizeId: $("#OrganizeId").val() },
            url: "/SysConfig/GetGridJson",
            height: $(window).height() - 128,
            colModel: [
                 { label: "主键", name: "Id", hidden: true, key: true },
                  { label: "名称", name: "Name", width: 80, align: 'left' },
                  { label: '编码', name: 'Code', width: 80, align: 'left' },
                  { label: 'Value', name: 'Value', width: 300, align: 'left' },
                  { label: '说明', name: 'Memo', width: 150, align: 'left' },
                  { label: '排序', name: 'px', width: 50, align: 'left' },
                   {
                       label: "有效", name: "zt", width: 60, align: "center",
                       formatter: function (cellvalue) {
                           return cellvalue == "1" ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
                       }
                   },
                  { label: '修改用户', name: 'CreatorCode', width: 150, align: 'left' },
                     {
                         label: '创建时间', name: 'CreateTime', width: 80, align: 'left',
                         formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' }
                     },
            ],
            pager: "#gridPager",
            sortname: 'CreateTime desc',
        });
        $("#btn_search").click(function () {
            $("#gridList").jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val(), organizeId: $("#OrganizeId").val() },
            }).trigger('reloadGrid');
        });
    }

    function initControl() {
        $("#OrganizeId").bindSelect({
            url: "/Organize/GetChildTreeSelectJson",
        });
        $("#OrganizeId").change(function () {
            $("#btn_search").trigger('click');
        });
    }

    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增配置",
            url: "/SysConfig/Form",
            width: "550px",
            height: "570px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }

    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().Id;
        $.modalOpen({
            id: "Form",
            title: "修改配置",
            url: "/SysConfig/Form?keyValue=" + keyValue,
            width: "550px",
            height: "570px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }

    function btn_ShowAllConfig() {
        $.modalOpen({
            id: "Form",
            title: "查看所有配置项",
            url: "/SystemManage/SysConfig/ConfigsPreviewIndex",
          width: "850px",
            height: "570px",
            btn: null
        });
    }

</script>
<div class="topPanel">
    <div style="float:left;margin-left:10px;width:200px;">
        <select id="OrganizeId" name="OrganizeId" class="form-control required"></select>
    </div>
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建项目</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-edit" authorize="yes" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改配置</a></li>
                <li class="split"></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="配置名称/配置代码" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div style="float:right;padding-right:100px;">
        <a title="查看所有配置项" onclick="btn_ShowAllConfig()" style="cursor:pointer;color:blue;text-decoration:underline;">配置项</a>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>


